using HMEngine.HMComponents;
using Microsoft.Xna.Framework.Content;
using Microsoft.Xna.Framework.Graphics;

namespace HMEngine.HMEffects {
    public delegate void HMEffectParameterHandler(Effect myEffect, IHMRenderable renderable);

    public class HMEffect : IHMLoadable {
        private readonly string myAsset;
        public event HMEffectParameterHandler SetUserParameters;

        internal Effect Effect { get; private set; }

        protected HMEffect(string asset) { myAsset = asset; }

        public virtual void SetParameters(IHMRenderable renderable) {
            if (null != SetUserParameters) {
                SetUserParameters(Effect, renderable);
            }

            Effect.CommitChanges();
        }

        public virtual void LoadContent(GraphicsDevice myDevice, ContentManager myLoader) { Effect = myLoader.Load<Effect>(myAsset); }
        public virtual void UnloadContent() { }
    }
}